# -*- coding: utf-8 -*-

import Image
import hashlib

from codename_bamboo.preference import IMAGE_TYPE, AVATAR_SIZE

def __hash_password(raw_password):
    message = hashlib.md5(raw_password.encode('utf-8'))

    return message.hexdigest()

def __make_avatar(raw_file, password):
    raw_image = Image.open(raw_file)
    raw_image.thumbnail((AVATAR_SIZE), Image.ANTIALIAS)
    image = '/tmp/' + password + '.' + IMAGE_TYPE
    raw_image.save(image, IMAGE_TYPE)

    return open(image, 'r')

